import {Component, Input, OnInit} from '@angular/core';
import { Hero } from '../hero';
import {HeroService} from "../hero.service";

@Component({
  selector: 'app-hero-detail',
  templateUrl: './hero-detail.component.html',
  styleUrls: ['./hero-detail.component.css']
})
export class HeroDetailComponent implements OnInit {

  constructor(private heroService: HeroService) { }

  @Input() hero: Hero;

  ngOnInit() {
  }

  save(): void {
    this.heroService.updateHero(this.hero)
      .subscribe(history.back);
  }
}
